<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/11/8 0008
 * Time: 下午 7:46
 */

namespace app\controller;


use app\middleware\Check;
use think\facade\Cache;
use think\facade\Cookie;
use think\facade\Lang;
use think\facade\Session;

class Store
{

   // protected  $middleware = [Check::class];
    protected  $middleware = [
        'check'=>['only'=>'upload']
        //'Auth'=>[

    ];
    function index(){

        //Session::set("name","tom");
        //Session::set("age","555");
        //return Session::get("name");
        //dump(Session::all());
        //Session::delete("age");
        //return request()->session("age");
        //dump(Session::has("age"));
        //Session::delete("age");
        //Session::clear();
        //return Session::pull("age");

        //Session::flash("v",101);

        session("name","jack");
        echo session("?name");
        echo session("name");
        echo session("name","");
        echo session("name");
    }

    function get(){

        return Session::get("v");
    }

    function cookie(){

        //Cookie::set("name","huax",3600);

        //return Cookie::get("name");
        //return request()->cookie("name");
       // Cookie::forever("city","北京");

        Cookie::delete("city");

    }

    function cache(){

        Cache::set("name","jack");

        dump(Cache::get("name"));


    }

    function upload(){

        return view("upload");
    }

    function lang(){

        //英文切换：http://127.0.0.1:8090/store/lang?lang=en-us
        echo Lang::get("require_name");
        echo "<br/>";
        echo lang("email_error");

        return view("lang",[
            "ok"=>"nice"
        ]);

    }

    function middleware(){

        return view("middleware");
    }

    function auth($id){

        return "auth id".$id;
    }
}